package com.linzm.servlet;

import com.linzm.model.Request;
import com.linzm.model.Response;
import com.linzm.utils.HttpProtocolUtil;
import lombok.SneakyThrows;

import java.io.IOException;
import java.util.concurrent.TimeUnit;

/**
 * @Date: 2023/11/7 20:37
 * @User linziming
 */
public class DxhServlet extends HttpServlet {
    @SneakyThrows
    @Override
    public void doGet(Request request, Response response) {
        String content = "<h1>DxhServlet get</h1>";
        try {
            response.output(HttpProtocolUtil.getHttpHeader200(content.getBytes().length) + content);
            TimeUnit.SECONDS.sleep(100);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void doPost(Request request, Response response) {
        String content = "<h1>DxhServlet post</h1>";
        try {
            response.output(HttpProtocolUtil.getHttpHeader200(content.getBytes().length) + content);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
